package com.market.service.impl;

import com.market.common.exception.ServiceException;
import com.market.common.vo.ResponseCode;
import com.market.entity.Sales;
import com.market.mapper.SalesMapper;
import com.market.service.SalesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SalesServiceImpl implements SalesService {
    @Resource
    SalesMapper salesMapper;


    /**
     * 终端销售单
     *
     * @return
     */
    @Override
    public Sales salesInquire() {
        Sales sales = salesMapper.salesInquire();
        return sales;
    }

    /**
     * 终端销售单详细查询
     *
     * @return
     */
    @Override
    public Sales salesDetailed(Integer id) {
        Sales salesdetailed = salesMapper.salesdetailed(id);
        return salesdetailed;
    }

    /**
     * 终端退货单查询
     *
     * @return
     */
    @Override
    public List<Sales> salesReturn() {
        List<Sales> salesreturn = salesMapper.salesreturn();
        return salesreturn;
    }

    /**
     * 终端退货单详细查询
     * * @param salesId
     *
     * @return
     */
    @Override
    public Sales returnDetailed(Integer id) {
        Sales sales = salesMapper.returnDetailed(id);
        return sales;
    }

    /**
     * 终端销售单-编码查询
     * @param coding
     * @return
     */
    @Override
    public Sales selectCoding(String coding) {
        Sales sales = null;
        if ("".equals(coding)) {
            throw new ServiceException(ResponseCode.ERROR);
        } else {
            sales = salesMapper.selectCoding(coding);
        }
        return sales;
    }

    @Override
    public Sales returnCoding(String coding) {
        Sales sales = salesMapper.returnCoding(coding);
        return sales;
    }
}
